package com.opteron.action;

import java.io.File;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.SessionAware;
import org.springframework.stereotype.Controller;

import com.opteron.model.UserInfo;

@Controller
public class FileityAction extends BasesAction implements SessionAware {

	
	private static final long serialVersionUID = 1L;
	private Map<String, Object> session;
	private File file;
	private String[] fileName;
	private String fileFileName;
	private List<UserInfo>userList;
	private Map<String, Object> param3;
	private List<UserInfo> user;
	
	public String fileMain() {
		if(session.get("user") == null) {
			return SUCCESS;
		}
		session.clear();
		return SUCCESS;
	}
	
	public String fileUpload() {
		System.out.println(file);
		System.out.println(fileFileName);
		return SUCCESS;
	}
	public String testRetModel() {
		return SUCCESS;
	}
	public String testRetModelList() {
		try{
			HttpServletRequest request = ServletActionContext.getRequest();
			Map<String, String[]> m = request.getParameterMap();
			for(String k : m.keySet()) {
				for(String sr: m.get(k)) {
					System.out.println(sr);
				}
			}
			
			userList = getParameter2("userList");
			if(userList != null) {
				for(UserInfo u : userList) {
					System.out.println(u);
				}
			}
		} catch(Exception e) {
			System.out.println(e);
		}
		return SUCCESS;
	}
	
	public String testPost() {
		System.out.println(user);
		return SUCCESS;
	}
	
	@Override
	public void setSession(Map<String, Object> session) {
		this.session = session;
	}

	public File getFile() {
		return file;
	}

	public String[] getFileName() {
		return fileName;
	}

	public void setFile(File file) {
		this.file = file;
	}

	public void setFileName(String[] fileName) {
		this.fileName = fileName;
	}

	public String getFileFileName() {
		return fileFileName;
	}

	public void setFileFileName(String fileFileName) {
		this.fileFileName = fileFileName;
	}

	public List<UserInfo> getUserList() {
		return userList;
	}

	public void setUserList(List<UserInfo> userList) {
		this.userList = userList;
	}

	public Map<String, Object> getParam3() {
		return param3;
	}

	public void setParam3(Map<String, Object> param3) {
		this.param3 = param3;
	}

	public List<UserInfo> getUser() {
		return user;
	}

	public void setUser(List<UserInfo> user) {
		this.user = user;
	}
}
